extends Talent
func init():
	name = "舰娘打捞"

func _connect():
	sys.main.connect("onBattleStart",self,"run")

func run():
	for i in sys.main.btChas:
		if i.team == 1:
			i.addBuff(Bf.new())
#6 7 8 9 10
func get_info():
	return "击杀敌方时，有[{rnd}%]概率捞起一名随机舰娘".format({"rnd":1+0.1*lv})

class Bf extends "../../azurlane_ctrl/AzurBuff.gd":
	func _init():
		attInit()
		dispel = 3
		id = "mindcube"
	func _connect():
		masCha.connect("onKillChara",self,"run")
	func run(atkInfo):
		var rngnum = sys.rndRan(1, 1000)
		if rngnum <= (10 + lv) and not atkInfo.hitCha.isSumm and atkInfo.hitCha.team == 2:
			var chas = getRndCha()
			for cha in chas:
				sys.main.player.addCha(cha)
				print("打捞成功:{0}".format({"0":cha.chaName}))
				var eff = sys.newEff("numHit", atkInfo.hitCha.position, false, 1)
				eff.setText("打捞成功！", "#FF0099")
				yield(sys.get_tree().create_timer(0.03), "timeout")

	#从当前池子中获得随机人物
	func getRndCha():
		var chas = []
		var rngnum = sys.rndRan(1, 1000)
		var rng = ""
		if rngnum <= 3:
			rng = sys.rndListItem(chaData.infosLv4)
		elif rngnum <= 60:
			rng = sys.rndListItem(chaData.infosLv3)
		elif rngnum <= 300:
			rng = sys.rndListItem(chaData.infosLv2)
		else:
			rng = sys.rndListItem(chaData.infosLv1)
		chas.append(sys.main.newChara(rng.id))
		return chas